<template>
     <Card>
        <template v-slot:header>
            <h3>欢迎登录</h3>
        </template>
        <CardForm text="登录" @click="login"></CardForm>
        <template v-slot:footer>
            <router-link to="/" class="text-muted">如果没有账号,请点击此处注册</router-link>
        </template>
        </Card>
</template>

<script>
import Card from "../components/Card";
import CardForm from "../components/CardForm";
export default {
    name:'Login',
    components:{
        Card,
        CardForm
    },
     methods:{
        login(username, password) {
            const user=this.$store.state.user
            if (username ==user.username && password ==user.password) {
                alert("登录成功");
                this.$router.push({path:'/home'})
            } else {
                alert("登录失败,请重新登录")
            }
        }
     }
}
</script>